package com.lcredu.mapper;

import com.lcredu.entity.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * @author 黎长容
 * @date 2025-07-31 23:35
 */
public interface UserMapperAnnotation {
    
    //一个人手上有几只宠物
    @Select(" select * from mybatis_user where id = #{userId}")
    @Results({
            @Result(property = "id",column = "id",id = true),
            @Result(property = "name",column = "name"),
            @Result(property = "pets",column = "id",many = @Many(select = "com.lcredu.mapper.PetMapperAnnotation.getPetByUserId"))
            
    })
    public User getUserById(Integer userId);
}
